1 using System.Collections;
2 using
System.Collections.Generic;
3 using
UnityEngine;
4
5 public
class SpawnRings : MonoBehaviour {
6
7     
public GameObject ring;
8     
public Transform spawnPoint;
9
10     
public int spawnCount;
11
12     
public float spawnTime, waveTime, startTime;
13
14     
private float min = -2f;
15     
private float max = 2f;
16
17     
void Start () {
18         StartCoroutine(Rings());
19     }
20     
21     
void Update () {
22         
23     }
24
25     IEnumerator Rings() {
26         
yield return new WaitForSeconds(startTime);
27         
while (true)
28         {
29             
for (int i = 0; i < spawnCount; i++)
30             {
31                 transform.position =
new Vector3(spawnPoint.position.x, Random.Range(min, max), spawnPoint.position.y);
32                 Quaternion spawnRotation = Quaternion.identity;
33
34                 Instantiate(ring, transform.position, spawnRotation);
35
36                 
yield return new WaitForSeconds(spawnTime);
37             }
38
39             
yield return new WaitForSeconds(waveTime);
40         }
41     }
42 }



Trò chơi Halloween vui nhộn trong UNITY Engine 10.804 lượt xem

Gõ tìm kiếm nhanh...